package source.table;

import source.kernel.DB;
import source.kernel.base.Table;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * @author Hai Thomson
 */
public class applications extends Table {
	public applications() {
		super("applications", "applicationid");
	}

	/**
	 *
	 * @param hostid
	 * @return
	 * @throws SQLException
	 */
	public List fetchApplicationsByHostid(String hostid) throws SQLException {
		String sql = " SELECT applications.name, applications.applicationid FROM items_applications, applications WHERE items_applications.applicationid = applications.applicationid " +
				"AND applications.hostid = ? GROUP BY items_applications.applicationid HAVING count( items_applications.applicationid) > 0 ORDER BY applications.name DESC";
		return DB.queryMapList(sql, hostid);
	}
}
